#pragma once

#include "Color.h"
#include "Brush.h"

enum penStyle
{
	nonePen,					
	solidPen,					
	hatchPen,					
	texturePen,					
	gradientPen,				
};

enum lineCap
{
	flatLineCap,         
	squareLineCap,       
	roundLineCap,        
	triangleLineCap,     
	squareAnchorLineCap, 
	roundAnchorLineCap,
	diamondAnchorLineCap,
	arrowAnchorLineCap  
};

enum dashCap
{
	flatdashCap,
	rounddashCap,
	triangledashCap
};

class Pen
{
public:
	Pen()
	{
		Reset();
		m_brush = new SolidBrush(Color::Black);
		m_width = 1.0f;
		m_penstyle = solidPen;
	}
	~Pen()
	{
		delete m_brush;
	}
	Pen(const Color& color, float width = 1.0f)
	{
		Reset();
		m_brush = new SolidBrush(color);
		m_width = width;
		m_penstyle = solidPen;
	}
	Pen(const Brush& brush, float width = 1.0f)
	{
		Reset(); 
		m_brush = brush.Clone(); 
		m_width = width;
		m_penstyle = solidPen;
	}
	Pen* Clone() const
	{
		Pen* newpen = new Pen;
		newpen->m_brush = m_brush->Clone(); 
		newpen->m_width = m_width;
		newpen->m_penstyle = m_penstyle;
		newpen->m_linecap = m_linecap;
		return newpen;
	}
	const Brush& GetBrush() const
	{
		return *m_brush;
	}

	void SetWidth(float value){m_width = value;}
	float GetWidth() const{return m_width;}

	void SetLineCap(lineCap startCap, lineCap endCap, dashCap dashCap)
	{
		SetStartCap(startCap);
		SetEndCap(endCap);
		SetDashCap(dashCap);
	}

	void SetStartCap(lineCap startCap){m_linecap.startCap = startCap;}
	lineCap GetStartCap() const{return m_linecap.startCap;}

	void SetEndCap(lineCap endCap){m_linecap.endCap = endCap;}
	lineCap GetEndCap() const{return m_linecap.endCap;}

	void SetDashCap(dashCap dashCap){m_linecap.dashCap = dashCap;}
	dashCap GetDashCap() const{return m_linecap.dashCap;}

protected:
	Pen(const Pen&){}
	void operator=(const Pen&){}

private:
	void Reset()
	{
		m_penstyle = nonePen;
		m_brush = NULL;
		m_width = 1.0f;
		m_linecap.startCap = flatLineCap;
		m_linecap.endCap = flatLineCap;
		m_linecap.dashCap = flatdashCap;
	}
	struct LineCap{lineCap startCap;lineCap endCap;dashCap dashCap;};
	Brush* m_brush;
	penStyle m_penstyle;

	float m_width;
	LineCap m_linecap;
};